package com.app.controller;

import com.app.model.CustomerModel;
import com.app.model.TrainEnrollModel;
import com.app.model.UserModel;
import com.app.model.VideoTrainModel;
import com.app.service.CustomerService;
import com.app.service.TrainEnrollService;
import com.app.service.UserService;
import com.app.service.VideoTrainService;
import com.app.util.CommonHelp;
import com.app.util.Result;
import com.app.util.TokenUtils;
import com.app.vo.VideoTrainVo;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.text.ParseException;
import java.util.List;


@Controller
@ResponseBody
public class VideoTrainController {


    @Autowired
    JdbcTemplate jdbcTemplate;
    @Autowired
    VideoTrainService videoTrainService;
    @Autowired
    UserService userService;


    //**
    // 查询视频培训列表
    // *
    @GetMapping("/getVideoTrainList")
    public Result<Object> getVideoTrainList(HttpServletRequest request) throws ParseException {
        int page  = Integer.valueOf(request.getParameter("page"));
        int limit = Integer.valueOf(request.getParameter("limit"));
        VideoTrainModel model = new VideoTrainModel();
        model.setPage((page - 1) * limit);
        model.setLimit(limit);
        Page<VideoTrainModel> modelList = videoTrainService.getListByModel(model);
        int count = videoTrainService.getModelByCount(model);
        VideoTrainVo vo =new VideoTrainVo();
        vo.setModelList(modelList.getRecords());
        vo.setCount(count);
        if(modelList!=null&&modelList.getRecords().size()>0)
        {
           return Result.success(vo);
        }
        return Result.success(null);
    }
}
